home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!zephyr.ens.tek.com!tekred!saab!billr
- From: billr@saab.CNA.TEK.COM (Bill Randle)
- Newsgroups: comp.sources.games
- Subject: v11i044: gb3 - Galactic Bloodshed, an empire-like war game [Ver. 2.0], Patch2f
- Message-ID: <6231@tekred.CNA.TEK.COM>
- Date: 28 Aug 90 19:36:00 GMT
- Sender: news@tekred.CNA.TEK.COM
- Lines: 2107
- Approved: billr@saab.CNA.TEK.COM
-
- Submitted-by: VANCLEEF@mps.ohio-state.edu
- Posting-number: Volume 11, Issue 44
- Archive-name: gb3/Patch2f
- Patch-To: gb3: Volume 10, Issue 1-14
-
-
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 6 (of 9)."
- # Contents: Docs/mount.doc client/map.c server/dock.c server/doship.c
- # server/name.c
- # Wrapped by billr@saab on Tue Aug 28 08:54:57 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'Docs/mount.doc' -a "${1}" != "-c" ; then
- echo shar: Renaming existing file \"'Docs/mount.doc'\" to \"'Docs/mount.doc.orig'\"
- mv -f 'Docs/mount.doc' 'Docs/mount.doc.orig'
- fi
- echo shar: Extracting \"'Docs/mount.doc'\" \(784 characters\)
- sed "s/^X//" >'Docs/mount.doc' <<'END_OF_FILE'
- XMOUNT Galactic Bloodshed MOUNT
- X
- X
- XNAME
- X mount -- mount a crystal into a ship's hyper-drive.
- X dismount -- dismount a crystal from the drive.
- X
- XSYNTAX
- X mount
- X dismount
- X
- XDESCRIPTION
- X
- X Normally, a ship requires a waiting period before a hyperspace
- Xjump can be executed. This requires powering up the drive for
- Xsome period of time. However, the charge-up time can been bypassed
- Xif a player has a crystal mounted. The effect of a crystal also
- Xallows the ship to jump farther and more fuel efficiently than
- Xfor a ship without a crystal mounted.
- X
- X In order to mount a crystal, the player must change scope to the
- Xship which is to have a crystal mounted. The ship must have a
- Xcrystal on board. A crystal can be dismounted using the 'dismount'
- Xcommand.
- X
- XSEE ALSO
- X crystal, order
- X
- END_OF_FILE
- if test 784 -ne `wc -c <'Docs/mount.doc'`; then
- echo shar: \"'Docs/mount.doc'\" unpacked with wrong size!
- fi
- # end of 'Docs/mount.doc'
- if test -f 'client/map.c' -a "${1}" != "-c" ; then
- echo shar: Renaming existing file \"'client/map.c'\" to \"'client/map.c.orig'\"
- mv -f 'client/map.c' 'client/map.c.orig'
- fi
- echo shar: Extracting \"'client/map.c'\" \(4750 characters\)
- sed "s/^X//" >'client/map.c' <<'END_OF_FILE'
- X/*
- X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
- X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. Restrictions in
- X * GB_copyright.h.
- X *
- X * map.c -- display sector map of current planet
- X *
- X * plot_surface(): Plot as much of the planet surface as possible.
- X * If the planet surface is complete, return. Else
- X * set MAP to FALSE, and wait for the next packet.
- X *
- X * plot_balance(): Try to synchronize with the last character that
- X * was output. Complete the current character, then
- X * the current line, then the current map. Clear
- X * MAP flag.
- X * bugs: Not clean if the packets become screwy. plot_balance has
- X * no way of recovering from errors. Starting the balance of the
- X * map with the last character in a row or the last character in
- X * the map might screw up everything. No testing for this case.
- X *
- X * Version 1.1 25-Jul-90 Hubert Bartels
- X * hgb@catalina.opt-sci.arizona.edu
- X * Made modifications to complete
- X * maps.
- X */
- X
- X#include "GB_copyright.h"
- X#define S_X (stdscr->_maxx - NAMESIZE)
- X#define S_Y (stdscr->_maxy - 1)
- X#define Midx ((S_X - NAMESIZE)/2.0)
- X#define Midy (S_Y /2.0)
- X#define DISP_DATA 1
- X
- X#include <curses.h>
- X#include <stdio.h>
- X
- X/*
- X Map completion code
- X*/
- X#define SHIFT_IN 0x10
- X#define SHIFT_OUT 0x20
- X
- Xextern int MAP; /* True if in map mode */
- Xextern int s_in_out; /* TRUE if this was to be a shiftin/out flag */
- X /* if not TRUE, then SHIFT_OUT or SHIFT_IN */
- X /* depending on the state of stand. */
- Xextern int curY; /* The current Y ( row), location */
- Xextern int curX; /* The current X ( col), location */
- Xextern int Maxx; /* The maximum X size */
- Xextern int Maxy; /* The maximum Y size */
- Xextern char *index(), *malloc();
- Xextern int have_inv;
- X
- Xplot_surface(t)
- Xchar *t;
- X{
- X register int x, y;
- X int stand, show;
- X char *u, *v;
- X extern int MAP;
- X extern int s_in_out;
- X extern int curX;
- X extern int curY;
- X extern int Maxx;
- X extern int Maxy;
- X
- X clear();
- X u = t + 1;
- X /* get planet name */
- X v = index(u, ';');
- X *v = 0;
- X move(0, 9);
- X printw("`%s'\n ", u);
- X
- X u = v + 1;
- X v = index(u, ';');
- X *v = 0;
- X Maxx = atoi(u);
- X
- X u = v + 1;
- X v = index(u, ';');
- X *v = 0;
- X Maxy = atoi(u);
- X
- X u = v + 1;
- X v = index(u, ';');
- X *v = 0;
- X show = atoi(u);
- X for (x = 0; x < Maxx; x++) printw("%d", x / 10);
- X printw("\n ");
- X for (x = 0; x < Maxx; x++) printw("%d", x % 10);
- X printw("\n");
- X u = v + 1;
- X for (y = 0; y < Maxy; y++) {
- X curY = y;
- X mvaddch(y + 3, 0, y / 10 + '0');
- X addch(y % 10 + '0');
- X for (x = 0; x < Maxx; x++) {
- X curX = x;
- X if( *u == '\0') {
- X MAP = TRUE;
- X s_in_out = TRUE;
- X refresh();
- X return;
- X }
- X if (*u++ == '0') stand = 0; else stand = 1;
- X if( *u == '\0') {
- X MAP = TRUE;
- X if( stand == 0)
- X s_in_out = SHIFT_OUT;
- X else
- X s_in_out = SHIFT_IN;
- X refresh();
- X return;
- X }
- X if (stand && have_inv) standout();
- X mvaddch(y + 3, x + 3, *u);
- X if (stand && have_inv) standend();
- X u++;
- X }
- X }
- X MAP = FALSE;
- X curY = curX = 0;
- X move(Maxy + 4, 0);
- X refresh();
- X}
- X/*
- X plot_balance tries to find out where the map was truncated,
- X and tries to continue from the last location written.
- X
- X Version 1.0 25-Jul-90 HGB, modified from plot_surface.
- X*/
- Xplot_balance(t)
- Xchar *t;
- X{
- X register int x, y;
- X int stand;
- X char *u;
- X extern int MAP;
- X extern int s_in_out;
- X extern int curY;
- X extern int curX;
- X extern int Maxx;
- X extern int Maxy;
- X/*
- X Check if we are supposed to be here.
- X*/
- X if( MAP == FALSE) return;
- X/*
- X Try to write the rest of the current row from the current buffer
- X also, we need to synchronize. If the first character is 0/1, this
- X is the standout/standin character. If the first character is not,
- X output this character.
- X*/
- X u = t;
- X y = curY;
- X x = curX;
- X/*
- X Synchronize. SHIFT_IN means we saw the standout flag, but
- X not the character. We draw the character, up the X counter,
- X and enter the balance of items loop for this row.
- X*/
- X if( s_in_out == SHIFT_IN && have_inv ) standout();
- X if( s_in_out != TRUE) {
- X mvaddch(y + 3, x + 3, *u);
- X if (s_in_out == SHIFT_IN && have_inv) standend();
- X curX++;
- X }
- X refresh();
- X/*
- X Now, draw the rest of the line.
- X*/
- X for( x = curX; x < Maxx; x++) {
- X if (*u == '0') stand = 0; else stand = 1;
- X u++;
- X if (stand && have_inv) standout();
- X mvaddch(y + 3, x + 3, *u);
- X if (stand && have_inv) standend();
- X u++;
- X }
- X refresh();
- X curY++;
- X/*
- X Try to draw the balance of the map, now. We should be synchronized.
- X*/
- X for (y = curY; y < Maxy; y++) {
- X mvaddch(y + 3, 0, y / 10 + '0');
- X addch(y % 10 + '0');
- X for (x = 0; x < Maxx; x++) {
- X if (*u == '0') stand = 0; else stand = 1;
- X u++;
- X if (stand && have_inv)
- X standout();
- X mvaddch(y + 3, x + 3, *u);
- X if (stand && have_inv)
- X standend();
- X u++;
- X }
- X refresh();
- X }
- X MAP = FALSE;
- X curX = curY = 0;
- X move(Maxy + 4, 0);
- X refresh();
- X return;
- X}
- END_OF_FILE
- if test 4750 -ne `wc -c <'client/map.c'`; then
- echo shar: \"'client/map.c'\" unpacked with wrong size!
- fi
- # end of 'client/map.c'
- if test -f 'server/dock.c' -a "${1}" != "-c" ; then
- echo shar: Renaming existing file \"'server/dock.c'\" to \"'server/dock.c.orig'\"
- mv -f 'server/dock.c' 'server/dock.c.orig'
- fi
- echo shar: Extracting \"'server/dock.c'\" \(13087 characters\)
- sed "s/^X//" >'server/dock.c' <<'END_OF_FILE'
- X/*
- X** Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
- X** smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
- X** Restrictions in GB_copyright.h.
- X**
- X** dock.c -- dock a ship
- X** and..... assault -- a very un-PC version of dock
- X*/
- X
- X#include "GB_copyright.h"
- X#define EXTERN extern
- X#include "vars.h"
- X#include "ships.h"
- X#include "races.h"
- X#include "buffers.h"
- X#include <signal.h>
- X#include <math.h>
- X
- Xint dock_sectdata, dock_shdata, dock_pdata, dock_racedata;
- Xint dock_stdata;
- X
- Xdock(Playernum,APcount, argn,args, Assault)
- Xint Playernum;
- Xint APcount;
- Xint argn;
- Xchar args[MAXARGS][COMMANDSIZE];
- Xint Assault; /* unfriendly dock */
- X{
- Xchar c;
- Xshiptype *s,*s2,*s3;
- Xplanettype *p;
- Xsectortype *sect;
- Xint boarders,oldspopn,olds2popn,dam,dam2,booby,
- X numdest=0,ship2no,shipno,x= -1,y= -1,i,mask;
- Xint old2owner,sh, sh3;
- Xint casualties, casualties2, casualty_scale;
- Xfloat fuel,bstrength,b2strength,pris;
- Xdouble Dist;
- Xracetype *Race, *alien;
- X
- Xdock_sectdata = dock_shdata = dock_pdata = NEUTRAL_FD;
- X
- X
- X sscanf(args[1]+(args[1][0]=='#'),"%d",&shipno);
- X sscanf(args[2]+(args[2][0]=='#'),"%d",&ship2no);
- X
- X
- X openshdata(&dock_shdata);
- X if (!getship(dock_shdata, &s, shipno)) {
- X notify(Playernum, "The ship wasn't found.\n");
- X close_file(dock_shdata);
- X return;
- X }
- Xclose_file(dock_shdata);
- X if (testship(Playernum,s, shipno)) {
- X notify(Playernum, "Illegal format.\n");
- X free(s);
- X return;
- X }
- X
- X if(!Assault) {
- X if (s->is_docked) {
- X sprintf(buf,"Ship #%d is already docked.\n",shipno);
- X notify(Playernum, buf);
- X free(s);
- X return;
- X }
- X } else if(s->is_docked) {
- X if(s->whatdest==LEVEL_PLAN) {
- X notify(Playernum, "Target ship is landed.\n");
- X free(s);
- X return;
- X } else if(!(s->whatdest==LEVEL_SHIP)) {
- X notify(Playernum, "Weird error..\n");
- X free(s);
- X return;
- X }
- X }
- X
- X if (s->whatorbits==LEVEL_UNIV) {
- X if (!enufAP(Playernum,Sdata.AP[Playernum-1], APcount)) {
- X free(s);
- X return;
- X }
- X } else if (!enufAP(Playernum,Stars[s->storbits]->AP[Playernum-1], APcount)) {
- X free(s);
- X return;
- X }
- X
- X
- X if(shipno==ship2no) {
- X notify(Playernum, "You can't dock with yourself!\n");
- X free(s);
- X return;
- X }
- X
- X
- Xopenshdata(&dock_shdata);
- X if (!getship(dock_shdata, &s2, ship2no)) {
- X notify(Playernum, "The ship wasn't found.\n");
- X close_file(dock_shdata);
- X free(s);
- X return;
- X }
- Xclose_file(dock_shdata);
- X/* if (testship(Playernum,s2, ship2no)) {
- X notify(Playernum, "Illegal format.\n");
- X free(s2);
- X free(s);
- X return;
- X }
- X*/
- X
- X if (s2->is_docked) {
- X sprintf(buf,"Ship #%d is already docked.\n",ship2no);
- X notify(Playernum, buf);
- X free(s);
- X free(s2);
- X return;
- X }
- X
- X
- X Dist = sqrt((double)Distsq(s2->xpos, s2->ypos, s->xpos, s->ypos ) );
- X fuel = 0.05 + Dist * 0.025 * (Assault ? 2.0 : 1.0)*sqrt(s->mass);
- X
- X if (Dist > DIST_TO_DOCK) {
- X sprintf(buf,"Ship #%d must be %.2f or closer to ship #%d.\n",
- X shipno, DIST_TO_DOCK, ship2no);
- X notify(Playernum, buf);
- X free(s);
- X free(s2);
- X return;
- X } else if(s->is_docked && Assault) {
- X/* first undock the target ship */
- X s->is_docked = 0;
- X s->whatdest==LEVEL_UNIV;
- X openshdata(&dock_shdata);
- X (void)getship(dock_shdata, &s3, s->destshipno);
- X s3->is_docked==0;
- X s3->whatdest==LEVEL_UNIV;
- X putship(dock_shdata, s3, s->destshipno);
- X free(s3);
- X }
- X
- X if (fuel > s->fuel) {
- X sprintf(buf,"Not enough fuel.\n");
- X notify(Playernum, buf);
- X free(s);
- X free(s2);
- X return;
- X }
- X sprintf(buf,"Distance to %s #%d: %.2f.\n", s2->name, ship2no, Dist);
- X notify(Playernum, buf);
- X sprintf(buf,"This maneuver will take %.2f fuel (of %.2f.)\n\n",fuel,s->fuel);
- X notify(Playernum, buf);
- X
- X
- X
- X if (s->type == STYPE_FIGHTER && s2->type == STYPE_CARRIER) {
- X /* docking fighters with a carrier */
- X
- X if(s->whatorbits==LEVEL_PLAN) {
- X openpdata(&dock_pdata);
- X getplanet(dock_pdata, &p, Stars[s->storbits]->planetpos[s->pnumorbits]);
- X sh = p->ships;
- X
- X if(sh == shipno) {
- X p->ships = s->nextship;
- X putplanet(dock_pdata, p, Stars[s->storbits]->planetpos[s->pnumorbits]);
- X } else {
- X openshdata(&dock_shdata);
- X while(sh != shipno){
- X (void)getship(dock_shdata, &s3, sh);
- X sh3 = sh;
- X sh = s3->nextship;
- X if(sh != shipno) free(s3); /* don't free it if it is the s3 we want */
- X }
- X s3->nextship = s->nextship;
- X putship(dock_shdata, s3, sh3);
- X free(s3);
- X if(sh3 == ship2no) { /* s3 was actually s2! */
- X free(s2);
- X (void)getship(dock_shdata, &s2, sh3);
- X }
- X close_file(dock_shdata);
- X
- X
- X }
- X close_file(dock_pdata);
- X } else if(s->whatorbits==LEVEL_STAR) {
- X openstardata(&dock_stdata);
- X getstar(dock_stdata, &Stars[s->storbits], s->storbits);
- X sh = Stars[s->storbits]->ships;
- X
- X if(sh == shipno) {
- X Stars[s->storbits]->ships = s->nextship;
- X putstar(dock_stdata, Stars[s->storbits], s->storbits);
- X } else {
- X openshdata(&dock_shdata);
- X while(sh != shipno){
- X (void)getship(dock_shdata, &s3, sh);
- X sh3 = sh;
- X sh = s3->nextship;
- X if(sh != shipno) free(s3); /* don't free it if it is the s3 we want */
- X }
- X s3->nextship = s->nextship;
- X putship(dock_shdata, s3, sh3);
- X free(s3);
- X if(sh3 == ship2no) { /* we just wrote it to disk! */
- X free(s2);
- X (void)getship(dock_shdata, &s2, s3);
- X }
- X close(dock_shdata);
- X
- X }
- X
- X close_file(dock_stdata);
- X } else {
- X notify(Playernum, "Illegal scope.\n");
- X free(s);
- X free(s2);
- X return;
- X }
- X
- X
- X s->fuel -= fuel;
- X s->mass -= fuel * MASS_FUEL;
- X s->is_docked = 1;
- X s->whatdest = LEVEL_SHIP;
- X s->whatorbits = LEVEL_UNIV;
- X s->destshipno = ship2no;
- X s->nextship = 0;
- X
- X s->xpos = s2->xpos;
- X s->ypos = s2->ypos;
- X
- X s->object.number = s2->object.number;
- X s->object.number4 = 1; /* docked with carrier */
- X
- X /* remove fighter from upper level linked list */
- X s2->object.number = shipno;
- X s2->object.number4 += 1; /* number of fighters docked */
- X s2->mass += s->mass;
- X
- X } else {
- X if (s2->is_docked && !Assault) {
- X sprintf(buf,"ship #%d is already docked.\n",ship2no);
- X notify(Playernum, buf);
- X free(s);
- X free(s2);
- X return;
- X }
- X
- X if (Assault) {
- X
- X openracedata(&dock_racedata);
- X getrace(dock_racedata, &alien, (int)s2->owner);
- X getrace(dock_racedata, &Race, Playernum);
- X close_file(dock_racedata);
- X
- X sscanf(args[3],"%d",&boarders);
- X if (boarders > MIN(s->popn, Max_crew(s2))
- X || boarders <= 0) {
- X sprintf(buf,"Illegal number of boarders (max can be %d).\n",
- X MIN(s->popn, Max_crew(s2)));
- X notify(Playernum, buf);
- X free(alien);
- X free(s);
- X free(s2);
- X return;
- X }
- X old2owner = s2->owner;
- X s->popn -= boarders;
- X s->mass -= boarders * Race->mass;
- X sprintf(buf,"Boarding strength :%.2f Defense strength: %.2f.\n",
- X bstrength = boarders * Race->fighters
- X * .01 * Race->tech
- X * .01 * (100 - s->damage),
- X /* 1 is dummy armor */
- X
- X b2strength = s2->popn * alien->fighters
- X * .01 * alien->tech
- X * .01 * (100 - s2->damage)
- X );
- X notify(Playernum, buf);
- X
- X }
- X
- X
- X /* the ship moves into position, regardless of success of attack */
- X s->fuel -= fuel;
- X s->mass -= fuel * MASS_FUEL;
- X
- X s->xpos = s2->xpos + int_rand(-1,1);
- X s->ypos = s2->ypos + int_rand(-1,1);
- X
- X if (Assault) {
- X/* if the assaulted ship is docked, undock it first */
- X if(s2->is_docked && s2->whatdest==LEVEL_SHIP) {
- X
- X openshdata(&dock_shdata);
- X getship(dock_shdata, &s3, s2->destshipno);
- X s3->is_docked = 0;
- X s3->whatdest = LEVEL_UNIV;
- X s3->destshipno = 0;
- X putship(dock_shdata, s3, s2->destshipno);
- X close_file(dock_shdata);
- X free(s3);
- X
- X s2->is_docked = 0;
- X s2->whatdest = LEVEL_UNIV;
- X s2->destshipno = 0;
- X }
- X /* nuke both populations, ships */
- X casualty_scale = MIN(boarders, s2->popn);
- X
- Xif(b2strength) { /* otherwise the ship surrenders */
- X casualties = int_rand(0, round_rand((float)casualty_scale * (b2strength+1.0) /
- X (bstrength+1.0)));
- X casualties = MIN(boarders, casualties);
- X boarders -= casualties;
- X
- X dam = int_rand(0, round_rand(25. * (b2strength+1.0)/ (bstrength+1.0)));
- X dam = MIN(100, dam);
- X s->damage = MIN(100, s->damage+dam);
- X if (s->damage >= 100)
- X kill_ship(Playernum, s);
- X
- X
- X casualties2 = int_rand(0, round_rand((float)casualty_scale * (bstrength+1.0) /
- X (b2strength+1.0)));
- X casualties2 = MIN(s2->popn, casualties2);
- X s2->popn -= casualties2;
- X s2->mass -= casualties2 * alien->mass;
- X /* (their mass) */
- X dam2 = int_rand(0,round_rand(25. * (bstrength+1.0)/(b2strength+1.0)));
- X dam2 = MIN(100, dam2);
- X s2->damage = MIN(100, s2->damage+dam2);
- X if ( s2->damage >= 100)
- X kill_ship(Playernum, s2);
- X} else {
- X s2->popn = 0; booby = 0;
- X/* do booby traps */
- X /* check for boobytrapping */
- X if (!Max_crew(s2) && s2->destruct > 0)
- X booby = int_rand(0, 10*s2->destruct);
- X booby = MIN(100, booby);
- X }
- X
- X if ((s2->popn == 0) && s->is_alive && s2->is_alive) {
- X /* we got 'em */
- X s->is_docked = 1;
- X s->whatdest = LEVEL_SHIP;
- X s->destshipno = ship2no;
- X
- X s2->is_docked = 1;
- X s2->whatdest = LEVEL_SHIP;
- X s2->destshipno = shipno;
- X old2owner = s2->owner;
- X s2->owner = Playernum;
- X s2->popn = boarders;
- X s2->mass += boarders * Race->mass; /* our mass */
- X } else { /* retreat */
- X s->popn += boarders;
- X s->mass += boarders * Race->mass;
- X }
- X
- X/* races find out about each other */
- X alien->translate[Playernum-1] = MIN(alien->translate[Playernum-1]+5, 100);
- X Race->translate[old2owner-1] = MIN(Race->translate[old2owner-1]+5, 100);
- X
- X if(!boarders && s2->popn) /* boarding party killed */
- X alien->translate[Playernum-1] = MIN(alien->translate[Playernum-1]+25, 100);
- X if(s2->owner==Playernum) /* captured ship */
- X Race->translate[old2owner-1] = MIN(Race->translate[old2owner-1]+25, 100);
- X
- X openracedata(&dock_racedata);
- X putrace(dock_racedata, Race, 7);
- X putrace(dock_racedata, alien, 8);
- X close_file(dock_racedata);
- X free(alien);
- X free(Race);
- X } else {
- X s->is_docked = 1;
- X s->whatdest = LEVEL_SHIP;
- X s->destshipno = ship2no;
- X
- X s2->is_docked = 1;
- X s2->whatdest = LEVEL_SHIP;
- X s2->destshipno = shipno;
- X }
- X
- X if (Assault) {
- X sprintf(telegram_buf,"%s #%d ASSAULTED by ",
- X Shipnames[s2->type], ship2no);
- X sprintf(buf,"%s #%d [%d] at %s\n",
- X Shipnames[s->type], shipno, s->owner, prin_ship_orbits(s2));
- X str_cat(telegram_buf, buf);
- X sprintf(buf,"Your damage: %d%%, theirs: %d%%.\n", dam2, dam);
- X str_cat(telegram_buf, buf);
- X if (!Max_crew(s2) && s2->destruct) {
- X sprintf(buf,"(Your boobytrap gave them %.0f%% damage.)\n",
- X booby);
- X str_cat(telegram_buf, buf);
- X sprintf(buf,"Their boobytrap gave you %.0f%% damage!)\n",
- X booby);
- X notify(Playernum, buf);
- X }
- X sprintf(buf,"Damage taken: You: %d%% (now %d%%)\n", dam, s->damage);
- X notify(Playernum, buf);
- Xif(!s->is_alive) {
- X sprintf(buf," YOUR SHIP WAS DESTROYED!!!\n");
- X notify(Playernum, buf);
- X sprintf(buf," Their ship DESTROYED!!!\n");
- X str_cat(telegram_buf, buf);
- X}
- X sprintf(buf," Them: %d%% (now %d%%)\n",dam2,s2->damage);
- X notify(Playernum, buf);
- Xif(!s2->is_alive) {
- X sprintf(buf," Their ship DESTROYED!!! Boarders are dead.\n");
- X notify(Playernum, buf);
- X sprintf(buf," YOUR SHIP WAS DESTROYED!!!\n");
- X str_cat(telegram_buf, buf);
- X}
- X if (s->is_alive) {
- X if (s2->owner==Playernum) {
- X sprintf(buf,"CAPTURED!\n");
- X str_cat(telegram_buf, buf);
- X sprintf(buf,"VICTORY! the ship is yours!\n");
- X notify(Playernum, buf);
- X if (boarders) {
- X sprintf(buf,"%d boarders move in.\n", boarders);
- X notify(Playernum, buf);
- X }
- X
- X } else if(s2->popn) {
- X sprintf(buf,"The boarding was repulsed; try again.\n");
- X notify(Playernum, buf);
- X sprintf(buf,"You fought them off!\n");
- X str_cat(telegram_buf, buf);
- X }
- X } else {
- X sprintf(buf,"The assault was too much for your bucket of bolts.\n");
- X notify(Playernum, buf);
- X sprintf(buf,"The assault was too much for their ship..\n");
- X str_cat(telegram_buf, buf);
- X }
- X if (s2->is_alive) {
- X if (!boarders) {
- X sprintf(buf,"Oh no! They killed your boarding party to the last man!\n");
- X notify(Playernum, buf);
- X }
- X
- X if (!s->popn) {
- X sprintf(buf,"You killed all their crew!\n");
- X str_cat(telegram_buf, buf);
- X }
- X } else {
- X sprintf(buf,"The assault weakened their ship too much!\n");
- X notify(Playernum, buf);
- X sprintf(buf,"Your ship was weakened too much!\n");
- X str_cat(telegram_buf, buf);
- X }
- X sprintf(buf,"Casualties: Yours: %d Theirs: %d\n", casualties2, casualties);
- X str_cat(telegram_buf, buf);
- X sprintf(buf,"Crew casualties: Yours: %d Theirs: %d\n", casualties, casualties2);
- X notify(Playernum, buf);
- X if(!notify(old2owner, telegram_buf))
- X push_message(TELEG_PLAYER_AUTO, old2owner, telegram_buf, TELEGRAM);
- X } else {
- X sprintf(buf,"%s #%d docked with %s #%d.\n",
- X Shipnames[s->type], shipno,
- X Shipnames[s2->type], ship2no);
- X notify(Playernum, buf);
- X }
- X
- X }
- X
- X s->notified = s2->notified = 0;
- X openshdata(&dock_shdata);
- X putship(dock_shdata, s, shipno);
- X putship(dock_shdata, s2, ship2no);
- X close_file(dock_shdata);
- X free(s2);
- X free(s);
- X
- X
- X}
- END_OF_FILE
- if test 13087 -ne `wc -c <'server/dock.c'`; then
- echo shar: \"'server/dock.c'\" unpacked with wrong size!
- fi
- # end of 'server/dock.c'
- if test -f 'server/doship.c' -a "${1}" != "-c" ; then
- echo shar: Renaming existing file \"'server/doship.c'\" to \"'server/doship.c.orig'\"
- mv -f 'server/doship.c' 'server/doship.c.orig'
- fi
- echo shar: Extracting \"'server/doship.c'\" \(17924 characters\)
- sed "s/^X//" >'server/doship.c' <<'END_OF_FILE'
- X/*
- X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
- X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
- X * Restrictions in GB_copyright.h.
- X * doship -- do one ship turn.
- X */
- X
- X#include "GB_copyright.h"
- X#define EXTERN extern
- X#include "vars.h"
- X#include "ships.h"
- X#include "races.h"
- X#include "doturn.h"
- X#include "power.h"
- X#include "buffers.h"
- X#include <math.h>
- X#include <strings.h>
- X
- X
- Xdoship(shipno,ship)
- Xint shipno;
- Xshiptype *ship;
- X{
- X int sh,sh2,j,shfdata, doship_racedata;
- X boolean trigger;
- Xracetype *Race;
- X
- X/*ship is active */
- X ship->active = 1;
- X
- X if (ship->is_alive && ship->owner) {
- X
- X/* for debugging */
- X if(ship->popn > Max_crew(ship))
- X ship->popn = Max_crew(ship);
- X if(ship->destruct > Max_destruct(ship))
- X ship->destruct = Max_destruct(ship);
- X if(ship->fuel > (float)Max_fuel(ship))
- X ship->fuel = (float)Max_fuel(ship);
- X
- X/* upgrade factory tech (if off) */
- X if(ship->type==OTYPE_FACTORY && !ship->on) {
- X openshdata(&doship_racedata);
- X getrace(doship_racedata, &Race, ship->owner);
- X close_file(doship_racedata);
- X ship->tech = Race->tech;
- X free(Race);
- X }
- X
- X /* repair radiation */
- X if (ship->rad) {
- X ship->active = 1;
- X /* irradiated ships are immobile.. */
- X /* kill off some people */
- X /* check to see if ship is active */
- X if(int_rand(1,100) <= ship->rad)
- X ship->active = 0;
- X ship->popn = round_rand(ship->popn * .80);
- X if (ship->rad >= (int)REPAIR_RATE)
- X ship->rad -= int_rand(0,(int)REPAIR_RATE);
- X else
- X ship->rad -= int_rand(0,ship->rad);
- X } else
- X ship->active = 1;
- X
- X if(!ship->popn && Max_crew(ship) && !ship->is_docked)
- X ship->whatdest = LEVEL_UNIV;
- X
- X
- X if (ship->whatorbits != LEVEL_UNIV
- X && Stars[ship->storbits]->nova_stage>0) {
- X /* damage ships from supernovae */
- X ship->damage += 5*Stars[ship->storbits]->nova_stage/(Armor(ship)+1);
- X if (ship->damage >= 100) {
- X kill_ship(1, ship);
- X return;
- X }
- X }
- X
- X if(ship->active)
- X Moveship(shipno, ship);
- X
- X ship->size = ship_size(ship); /* for debugging */
- X
- X if(ship->whatorbits != LEVEL_UNIV) {
- X/* printf("checking #%d\n",shipno); */
- X StarsInhab[ship->storbits] = 1;
- X setbit(Stars[ship->storbits]->inhabited, ship->owner);
- X setbit(Stars[ship->storbits]->explored, ship->owner);
- X if(ship->whatorbits == LEVEL_PLAN) {
- X planets[ship->storbits][ship->pnumorbits]->info[ship->owner-1].explored = 1;
- X }
- X }
- X/* just making sure */
- X
- X
- X /* add ships, popn to total count to add AP's */
- X Power[ship->owner-1].ships_owned++;
- X Power[ship->owner-1].resource += ship->resource;
- X Power[ship->owner-1].fuel += ship->fuel;
- X Power[ship->owner-1].destruct += ship->destruct;
- X Power[ship->owner-1].popn += ship->popn;
- X
- X if (ship->whatorbits==LEVEL_UNIV) {
- X Sdatanumships[ship->owner-1]++;
- X Sdatapopns[ship->owner] += ship->popn;
- X } else {
- X starnumships[ship->storbits][ship->owner-1]++;
- X /* add popn of ships to popn */
- X starpopns[ship->storbits][ship->owner-1] += ship->popn;
- X /* set inhabited for ship */
- X StarsInhab[ship->storbits] = 1;
- X setbit(Stars[ship->storbits]->inhabited, ship->owner);
- X setbit(Stars[ship->storbits]->explored, ship->owner);
- X }
- X
- X
- X
- X
- X if (ship->active) {
- X
- X /* bombard the planet */
- X if (can_bombard(ship) && ship->bombard
- X && ship->whatorbits==LEVEL_PLAN
- X && ship->whatdest==LEVEL_PLAN
- X && ship->deststar== ship->storbits
- X && ship->destpnum== ship->pnumorbits) {
- X /* ship bombards planet */
- X Stinfo[ship->storbits][ship->pnumorbits].inhab = 1;
- X }
- X
- X
- X
- X /* repair ship by the amount of crew it has */
- X /* industrial complexes can repair (robot ships
- X and offline factories can't repair) */
- X if (ship->damage && Repair(ship)) {
- X reg int drep,cost;
- X reg float maxrep;
- X maxrep = REPAIR_RATE;
- X /* stations repair for free, and ships docked with them */
- X if (ship->type==STYPE_STATION || !Shipdata[ship->type][ABIL_BUILD]
- X || (ship->is_docked && ship->whatdest==LEVEL_SHIP &&
- X ships[ship->destshipno]->type==STYPE_STATION) )
- X cost = 0.0;
- X else {
- X maxrep *= (float)ship->popn / (float)Max_crew(ship);
- X cost = 0.005 * maxrep * Cost(ship);
- X }
- X
- X if (cost > ship->resource)
- X {
- X drep = (int)maxrep * ship->resource / cost;
- X ship->resource = 0;
- X } else {
- X ship->resource -= cost;
- X drep = (int)maxrep;
- X }
- X
- X ship->mass -= cost * MASS_RESOURCE;
- X
- X if (drep > ship->damage) ship->damage = 0;
- X else
- X ship->damage -= drep;
- X }
- X
- X/* compute the mass of the ship (there is a wierd bug that changes
- X mass the wrong way) */
- X ship->mass = ((ship->type==OTYPE_TOXWC) ? 1.0 : Mass(ship))
- X + (float)ship->popn*races[ship->owner-1]->mass
- X + (float)ship->resource*MASS_RESOURCE
- X + (float)ship->fuel*MASS_FUEL
- X + (float)ship->destruct*MASS_DESTRUCT;
- X
- X switch (ship->type) {
- X
- X case OTYPE_CANIST:
- X if (ship->whatorbits == LEVEL_PLAN && !ship->is_docked) { short *t;
- X if (--ship->object.number) {
- X if ( Stinfo[ship->storbits][ship->pnumorbits].temp_add < -90 )
- X Stinfo[ship->storbits][ship->pnumorbits].temp_add = -100;
- X else
- X Stinfo[ship->storbits][ship->pnumorbits].temp_add -= 10;
- X } else { /* timer expired; destroy canister */
- X reg int j=0;
- X
- X kill_ship(1, ship);
- X sprintf(telegram_buf,"Notice from /%s/%s\n",
- X Stars[ship->storbits]->name,
- X Stars[ship->storbits]->pnames[ship->pnumorbits]);
- X sprintf(buf, "Canister of dust previously covering this planet has dissipated.\n");
- X str_cat(telegram_buf, buf);
- X for (j=1; j<=Num_races; j++)
- X if (planets[ship->storbits][ship->pnumorbits]->info[j-1].numsectsowned)
- X push_message(TELEG_PLAYER_AUTO, j, telegram_buf, TELEGRAM);
- X }
- X }
- X break;
- X
- X case STYPE_MIRROR:
- X switch (ship->aimed_at.level) {
- X case LEVEL_SHIP: /* ship aimed at is a legal ship now */
- X /* if in the same system */
- X if ( (ship->whatorbits==LEVEL_STAR || ship->whatorbits==LEVEL_PLAN)
- X && (ships[ship->aimed_at.shipno]!=NULL)
- X && (ships[ship->aimed_at.shipno]->whatorbits==LEVEL_STAR ||
- X ships[ship->aimed_at.shipno]->whatorbits==LEVEL_PLAN)
- X && ship->storbits == ships[ship->aimed_at.shipno]->storbits
- X && ships[ship->aimed_at.shipno]->is_alive ) {
- X shiptype *s;
- X reg int i;
- X float range;
- X s = ships[ship->aimed_at.shipno];
- X range = sqrt(Distsq(ship->xpos, ship->ypos,s->xpos,s->ypos));
- X i = int_rand(0,round_rand((2./((float)Size(s)))
- X *(float)ship->aimed_at.intensity/(range/PLORBITSIZE+1.0)));
- X sprintf(telegram_buf, "Space Mirror #%d %s [owner %d] aimed at ",
- X shipno, ship->name, ship->owner);
- X str_cat(telegram_buf, buf);
- X sprintf(buf, "%s #%d %s [owner %d] !\n",Shipnames[s->type],
- X ship->aimed_at.shipno, s->name, s->owner);
- X str_cat(telegram_buf, buf);
- X s->damage += i;
- X if(i) {
- X sprintf(buf, "\n%d%% damage done.\n",i);
- X str_cat(telegram_buf, buf);
- X }
- X if (s->damage >= 100) {
- X sprintf(buf, "%s #%d DESTROYED!!!\n",Shipnames[s->type],
- X ship->aimed_at.shipno);
- X kill_ship(ship->owner, s);
- X }
- X
- X push_message(TELEG_PLAYER_AUTO, s->owner, telegram_buf, TELEGRAM);
- X push_message(TELEG_PLAYER_AUTO, ship->owner, telegram_buf, TELEGRAM);
- X }
- X break;
- X case LEVEL_PLAN: { reg short *t;
- X reg int i;
- X float range;
- X range = sqrt(Distsq(ship->xpos, ship->ypos,
- X Stars[ship->storbits]->xpos
- X +planets[ship->storbits][ship->pnumorbits]->xpos,
- X Stars[ship->storbits]->ypos
- X +planets[ship->storbits][ship->pnumorbits]->ypos));
- X
- X if ( range > PLORBITSIZE )
- X i = PLORBITSIZE * ship->aimed_at.intensity/range;
- X else
- X i = ship->aimed_at.intensity;
- X
- X i = round_rand(.01*(100.0-(float)ship->damage)*(float)i);
- X Stinfo[ship->storbits][ship->aimed_at.pnum].temp_add += i;
- X
- X } break;
- X
- X case LEVEL_STAR: { float range;
- X /* have to be in the same system as the star; otherwise
- X it's not too fair.. */
- X if (ship->aimed_at.snum>0 &&
- X ship->aimed_at.snum < Sdata.numstars &&
- X ship->whatorbits > LEVEL_UNIV &&
- X ship->aimed_at.snum == ship->storbits)
- X Stars[ship->aimed_at.snum]->stability += random()&01;
- X } break;
- X case LEVEL_UNIV:
- X break;
- X }
- X break;
- X case STYPE_GOD:
- X /* gods have infinite power.... heh heh heh */
- X ship->fuel = Max_fuel(ship);
- X ship->popn = Max_crew(ship);
- X ship->destruct = Max_destruct(ship);
- X ship->resource = Max_resource(ship);
- X break;
- X
- X case OTYPE_AP: /* atmospheric processor */
- X /* if landed on planet, change conditions to be like race */
- X if (ship->is_docked && ship->whatdest==LEVEL_PLAN && ship->on) {
- X int j,d,a;planettype *p;
- X p = planets[ship->storbits][ship->pnumorbits];
- X if (ship->fuel >= 3.0) {
- X ship->fuel -= 3.0;
- X for (j=RTEMP+1; j<=OTHER; j++) {
- X if ( (d = races[ship->owner-1]->conditions[j] -
- X p->conditions[j]) != 0) {
- X
- X a = sgn(d)*int_rand(-1,
- X round_rand(MIN(3,d*sgn(d))
- X *(float)ship->popn/(float)Shipdata[OTYPE_AP][ABIL_MAXCREW]));
- X if (p->conditions[j] + a < 0)
- X p->conditions[j] = 0;
- X else if (p->conditions[j] + a > 100)
- X p->conditions[j] = 100;
- X else p->conditions[j] += a;
- X }
- X }
- X } else if (!ship->notified) {
- X ship->notified = 1;
- X msg_OOF(ship, shipno, telegram_buf);
- X }
- X }
- X break;
- X
- X case OTYPE_VN: /* Von Neumann machine */
- X do_VN(ship,shipno);
- X break;
- X
- X case OTYPE_BERS: /* Berserker */
- X /* (turn done in doplanet() ) */
- X break;
- X
- X case STYPE_ASS:
- X /* "indimidate" the planet below, for enslavement purposes. */
- X if (ship->whatorbits==LEVEL_PLAN)
- X Stinfo[ship->storbits][ship->pnumorbits].intimidated = 1;
- X break;
- X
- X case OTYPE_OMCL:
- X /* orbital mind control laser */
- X if (ship->aimed_at.level==LEVEL_PLAN && ship->on &&
- X ship->speed==1) {
- X planets[ship->aimed_at.snum][ship->aimed_at.pnum]
- X ->is_sheep = 1;
- X }
- X break;
- X
- X case STYPE_HABITAT:{ reg int add;
- X /* habitats multiply some resources inside them. */
- X add = ship->resource *
- X ((float)ship->popn / Shipdata[STYPE_HABITAT][ABIL_MAXCREW])
- X * (100 - ship->damage) * 0.0005;
- X if (ship->resource+add > Shipdata[STYPE_HABITAT][ABIL_CARGO])
- X add = Shipdata[STYPE_HABITAT][ABIL_CARGO] - ship->resource;
- X ship->resource += add;
- X ship->mass += add * MASS_RESOURCE;
- X add = ship->popn * races[ship->owner-1]->birthrate *
- X (100 - ship->damage) * 0.002;
- X if (ship->popn+add > Shipdata[STYPE_HABITAT][ABIL_MAXCREW])
- X add = Shipdata[STYPE_HABITAT][ABIL_MAXCREW] - ship->popn;
- X ship->popn += add;
- X ship->mass += add * races[ship->owner-1]->mass;
- X } break;
- X
- X case STYPE_POD:
- X if (ship->notified) {
- X /* we just arrived at this system -- explode */
- X /* or, we are floating in space with no fuel -- just die */
- X reg int i,f;
- X
- X f = -1;
- X kill_ship(1, ship);
- X if (ship->whatorbits==LEVEL_STAR) {
- X
- X i = int_rand(0,Stars[ship->storbits]->numplanets - 1);
- X
- X if(int_rand(1,4)==1)
- X f = i;
- X
- X sprintf(telegram_buf, "Bulletin\n\nSpore pod #%d has warmed and exploded.\n",shipno);
- X if (f != -1) {
- X sprintf(buf,"A spore has landed on planet %s.\n",Stars[ship->storbits]->pnames[f]);
- X Stinfo[ship->storbits][f].Thing_add = ship->owner;
- X /* so doplanet does not pass over it */
- X StarsInhab[ship->storbits] = 1;
- X setbit(Stars[ship->storbits]->inhabited,ship->owner);
- X setbit(Stars[ship->storbits]->explored, ship->owner);
- X planets[ship->storbits][f]->info[ship->owner-1].explored = 1;
- X } else {
- X sprintf(buf,"No spores have survived.\n");
- X }
- X str_cat(telegram_buf, buf);
- X push_message(TELEG_PLAYER_AUTO, ship->owner, telegram_buf);
- X sprintf(telegram_buf,"BULLETIN!\n\n A spore pod has exploded in system /%s.\n",
- X Stars[ship->storbits]->name);
- X sprintf(buf, "Spores may have drifted to planets here.\n");
- X str_cat(telegram_buf, buf);
- X for (i=1; i<=Num_races; i++)
- X if (i!=ship->owner && isset(Stars[ship->storbits]->inhabited,i))
- X push_message(TELEG_PLAYER_AUTO, i, telegram_buf, TELEGRAM);
- X
- X }
- X }
- X break;
- X
- X default:
- X break;
- X }
- X
- X }
- X
- X } else if (!ship->is_alive && !ship->notified) {
- X /* ship is dead -- add to shipfree file, remove from all lists. */
- X /* if notified, this means it's already been deleted and written. */
- X/* printf("destroyed ship #%d\n",shipno);*/
- X if (ship->type == OTYPE_VN || ship->type==OTYPE_BERS) {
- X
- X /* add ship to VN shit list */
- X
- X if (ship->object.number3>0 && ship->object.number3<=Num_races
- X && ship->object.number3 != ship->owner) {
- X Sdata.VN_hitlist[ship->object.number3-1] += ship->object.number;
- X
- X /* keep track of where these VN's were shot up */
- X
- X if (Sdata.VN_index1[ship->object.number3-1] == -1)
- X /* there's no star in the first index */
- X Sdata.VN_index1[ship->object.number3-1] = ship->storbits;
- X else if (Sdata.VN_index2[ship->object.number3-1] == -1)
- X /* there's no star in the second index */
- X Sdata.VN_index2[ship->object.number3-1] = ship->storbits;
- X else {
- X /* pick an index to supplant */
- X if (random()&01)
- X Sdata.VN_index1[ship->object.number3-1] = ship->storbits;
- X else
- X Sdata.VN_index2[ship->object.number3-1] = ship->storbits;
- X }
- X printf("\t-- added %d ships, player %d\n",
- X ship->object.number, ship->object.number3);
- X }
- X }
- X ship->notified = 1;
- X makeshipdead(shipno);
- X }
- X
- X}
- X
- X
- Xdomine(shipno, detonate)
- Xint shipno;
- Xint detonate;
- X{
- X int sh,sh2,j,shfdata,pdata,rdata,hits;
- X boolean trigger;
- X shiptype *s, *ship;
- X planettype *planet;
- X racetype *r;
- X
- X openshdata(&shfdata);
- X getship(shfdata, &ship, shipno);
- X close_file(shfdata);
- X
- Xif(ship->is_alive && ship->owner)
- Xswitch(ship->type) {
- X case STYPE_MINE:
- X /* check around and see if we should explode. */
- X if (ship->on || detonate) {
- X int rad=0; int dam=0; double xd,yd,range; int p;
- X
- X switch(ship->whatorbits) {
- X case LEVEL_STAR:
- X sh = Stars[ship->storbits]->ships;
- X break;
- X case LEVEL_PLAN:
- X openpdata(&pdata);
- X getplanet(pdata, &planet, Stars[ship->storbits]->planetpos[ship->pnumorbits]);
- X sh = planet->ships;
- X close_file(pdata);
- X free(planet);
- X break;
- X default:
- X free(ship);
- X return;
- X break;
- X }
- X
- X sh2 = sh;
- X /* traverse the list, look for ships that
- X are closer than the trigger radius... */
- X/*printf("found mine sh = %d rad = %d\n",sh,rad);*/
- X rad = 0;
- X if(!detonate) {
- X openracedata(&rdata);
- X getrace(rdata, &r, ship->owner);
- X close_file(rdata);
- X
- X openshdata(&shfdata);
- X while (sh && !rad) {
- X getship(shfdata, &s, sh);
- X getship(shfdata, &s, sh);
- X if(s->is_docked && s->whatdest==LEVEL_PLAN) {
- X xd = ship->xpos;
- X yd = ship->ypos;
- X } else {
- X xd = s->xpos - ship->xpos;
- X yd = s->ypos - ship->ypos;
- X }
- X range = sqrt(xd*xd + yd*yd);
- X
- X if( !isset(r->allied, s->owner) &&
- X (s->owner != ship->owner) &&
- X ( (int)range <= ship->object.number) )
- X rad = 1;
- X else
- X sh = s->nextship;
- X
- X free(s);
- X }
- X close_file(shfdata);
- X free(r);
- X } else
- X rad = 1;
- X/*printf("rad = %d\n",rad);*/
- X if (rad) {
- X char telegram_not[1000];
- X kill_ship(ship->owner, ship);
- X sprintf(telegram_buf, "Mine #%d triggered at %s\n",
- X shipno,prin_ship_orbits(ship));
- X
- X /* I have made the blast radius equal to the trigger radius.*/
- X /* -R. */
- X
- X sh = sh2 ; /* Make sh start from beginning of the list */
- X openshdata(&shfdata);
- X while (sh) {
- X getship(shfdata, &s, sh);
- X if(s->is_docked && s->whatdest==LEVEL_PLAN) {
- X xd = ship->xpos;
- X yd = ship->ypos;
- X } else {
- X xd = s->xpos - ship->xpos;
- X yd = s->ypos - ship->ypos;
- X }
- X range = sqrt(xd*xd + yd*yd);
- X if(!detonate)
- X trigger = (int_rand(1,100)<= 2 * Size(s));
- X
- X if (s->is_alive && sh != shipno &&
- X (detonate || (range <= ship->object.number && trigger))) {
- X
- X if (!ship->mode) {
- X /* radiation mine */
- X
- X hits =MIN(ship->destruct,
- X (int)(ship->destruct/(range/100.0+1.0)));
- X rad = MAX(0, 20*(hits - Armor(s)) / Size(s));
- X
- X rad = int_rand(0, rad);
- X rad = MIN(rad ,100);
- X
- X if (rad > s->rad) {
- X s->rad = MAX(rad, s->rad);
- X if(int_rand(1,100) <= s->rad)
- X s->active = 0;
- X
- X sprintf(telegram_not, "%s #%d %s irradiated by mine #%d\n", Shipnames[s->type], sh, s->name, shipno);
- X sprintf(buf," at %s - dosage %d%%\n",prin_ship_orbits(s), rad);
- X str_cat(telegram_not, buf);
- X push_message(TELEG_PLAYER_AUTO, s->owner, telegram_not, TELEGRAM);
- X sprintf(buf,"%s #%d [%d] received %d%% dosage\n",
- X Shipnames[s->type], sh,
- X s->owner, rad);
- X str_cat(telegram_buf, buf);
- X }
- X
- X } else {
- X int totaldam;
- X /* explosive mine */
- X
- X hits =MIN(ship->destruct,
- X (int)(ship->destruct/(range/100.0+1.0)));
- X dam = MAX(0, 20*(hits - Armor(s)) / Size(s));
- X
- X dam = int_rand(0, dam);
- X dam = MIN(100, dam);
- X if (dam) {
- X s->damage = MIN(100, s->damage+dam);
- X sprintf(telegram_not, "%s #%d %s damaged by mine #%d\n",
- X Shipnames[s->type], sh, s->name, shipno);
- X sprintf(buf," at %s - %d %% damage", prin_ship_orbits(ship), dam);
- X str_cat(telegram_not, buf);
- X sprintf(buf,"%s #%d [%d] received %d%% damage\n",
- X Shipnames[s->type], sh,
- X s->owner, dam);
- X str_cat(telegram_buf, buf);
- X if (s->damage >= 100) {
- X kill_ship(ship->owner, s);
- X sprintf(buf, " %s #%d DESTROYED\n",Shipnames[s->type],sh);
- X str_cat(telegram_not, buf);
- X sprintf(buf,"\t--DESTROYED\n");
- X str_cat(telegram_buf, buf);
- X }
- X if(!notify(s->owner, telegram_not))
- X push_message(TELEG_PLAYER_AUTO, s->owner, telegram_not, TELEGRAM);
- X }
- X }
- X
- X putship(shfdata, s, sh);
- X }
- X
- X sh = s->nextship;
- X free(s);
- X }
- X close_file(shfdata);
- X }
- X if(!notify(ship->owner, telegram_buf))
- X push_message(TELEG_PLAYER_AUTO, ship->owner, telegram_buf,
- X TELEGRAM);
- X
- X openshdata(&shfdata);
- X putship(shfdata, ship, shipno);
- X close_file(shfdata);
- X }
- X break;
- X default:
- X break;
- X }
- Xfree(ship);
- X}
- X
- END_OF_FILE
- if test 17924 -ne `wc -c <'server/doship.c'`; then
- echo shar: \"'server/doship.c'\" unpacked with wrong size!
- fi
- # end of 'server/doship.c'
- if test -f 'server/name.c' -a "${1}" != "-c" ; then
- echo shar: Renaming existing file \"'server/name.c'\" to \"'server/name.c.orig'\"
- mv -f 'server/name.c' 'server/name.c.orig'
- fi
- echo shar: Extracting \"'server/name.c'\" \(17264 characters\)
- sed "s/^X//" >'server/name.c' <<'END_OF_FILE'
- X/*
- X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
- X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
- X * Restrictions in GB_copyright.h.
- X *
- X * name.c -- rename something to something else
- X* announce.c -- make announcements in the system you currently in.
- X* You must be inhabiting that system for your message to sent.
- X* You must also be in that system (and inhabiting) to receive announcements.
- X* page.c -- send a message to a player requesting his presence in a system.
- X*/
- X
- X#include "GB_copyright.h"
- X#define EXTERN extern
- X#include "vars.h"
- X#include "races.h"
- X#include "ships.h"
- X#include "buffers.h"
- X#include <ctype.h>
- X#include <signal.h>
- X#include <strings.h>
- X#include <time.h>
- Xint name_shdata,name_stardata, name_racedata, name_pdata;
- Xint i;
- X
- Xchar msg[1024];
- Xstruct tm *current_tm;/* for watching for next update */
- Xlong clk;
- X
- Xgive(Playernum, APcount, argn, args)
- Xint Playernum;
- Xint APcount;
- Xint argn;
- Xchar args[MAXARGS][COMMANDSIZE];
- X{
- Xint who, sh;
- Xshiptype *ship;
- Xplanettype *planet;
- Xracetype *Race, *alien;
- X
- XGetPlayer(args[1], &who, &alien);
- X if (who < 1 || who > Numraces() ) {
- X sprintf(buf,"No such player.\n");
- X notify(Playernum, buf);
- X return;
- X }
- X
- Xopenracedata(&name_racedata);
- Xgetrace(name_racedata, &Race, Playernum);
- Xclose_file(name_racedata);
- X
- X/* check to see if both players are mutually allied */
- Xif(!(isset(Race->allied, who) && isset(alien->allied, Playernum))) {
- X notify(Playernum, "You two are not mutually allied.\n");
- X free(Race);
- X free(alien);
- X return;
- X}
- Xsscanf(args[2]+(args[2][0]=='#'), "%d", &sh);
- X
- X openshdata(&name_shdata);
- X if(!getship(name_shdata, &ship, sh)) {
- X notify(Playernum, "Illegal ship number.\n");
- X close_file(name_shdata);
- X free(Race);
- X free(alien);
- X return;
- X }
- X close_file(name_shdata);
- X
- X if(ship->owner != Playernum || !ship->is_alive) {
- X DontOwnErr(Playernum, sh);
- X free(ship);
- X free(Race);
- X free(alien);
- X return;
- X }
- Xif(ship->type == STYPE_POD) {
- X notify(Playernum, "You cannot change the ownership of spore pods.\n");
- X free(ship);
- X free(Race);
- X free(alien);
- X return;
- X}
- X
- Xif(ship->popn && !Race->God) {
- X notify(Playernum, "You can't give this ship away while it has crew on board.\n");
- X free(ship);
- X free(Race);
- X free(alien);
- X return;
- X }
- X
- Xswitch(ship->whatorbits) {
- X case LEVEL_UNIV:
- X if(!enufAP(Playernum, Sdata.AP[Playernum-1], APcount)) {
- X free(Race);
- X free(alien);
- X free(ship);
- X return;
- X }
- X break;
- X default:
- X if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount)) {
- X free(Race);
- X free(alien);
- X free(ship);
- X return;
- X }
- X break;
- X }
- X
- Xopenshdata(&name_shdata);
- Xship->owner = who;
- Xputship(name_shdata, ship, sh);
- Xclose_file(name_shdata);
- X
- X/* set inhabited/explored bits */
- Xswitch(ship->whatorbits) {
- X case LEVEL_UNIV:
- X break;
- X case LEVEL_STAR:
- X free(Stars[ship->storbits]);
- X openstardata(&name_stardata);
- X getstar(name_stardata, &(Stars[ship->storbits]), ship->storbits);
- X setbit(Stars[ship->storbits]->inhabited, who);
- X setbit(Stars[ship->storbits]->explored, who);
- X putstar(name_stardata, Stars[ship->storbits], ship->storbits);
- X close_file(name_stardata);
- X break;
- X case LEVEL_PLAN:
- X free(Stars[ship->storbits]);
- X openstardata(&name_stardata);
- X getstar(name_stardata, &(Stars[ship->storbits]), ship->storbits);
- X setbit(Stars[ship->storbits]->inhabited, who);
- X setbit(Stars[ship->storbits]->explored, who);
- X putstar(name_stardata, Stars[ship->storbits], ship->storbits);
- X close_file(name_stardata);
- X
- X openpdata(&name_pdata);
- X getplanet(name_pdata, &planet, Stars[ship->storbits]->planetpos[ship->pnumorbits]);
- X planet->info[who-1].explored = 1;
- X putplanet(name_pdata, planet, Stars[ship->storbits]->planetpos[ship->pnumorbits]);
- X close_file(name_pdata);
- X free(planet);
- X
- X break;
- X default:
- X notify(Playernum, "Something wrong with this ship's scope.\n");
- X free(ship);
- X free(Race);
- X free(alien);
- X return;
- X break;
- X}
- X
- Xswitch(ship->whatorbits) {
- X case LEVEL_UNIV:
- X deductAPs(Playernum, APcount, 0, 1);
- X free(Race);
- X free(alien);
- X free(ship);
- X return;
- X break;
- X default:
- X deductAPs(Playernum,APcount, Dir[Playernum-1].snum, 0);
- X break;
- X }
- X
- X
- Xnotify(Playernum, "Owner changed.\n");
- Xsprintf(buf, "%s [%d] gave you %s #%d at %s.\n", Race->name, Playernum,
- X Shipnames[ship->type], sh, prin_ship_orbits(ship));
- Xnotify(who, buf);
- Xpush_message(TELEG_PLAYER_AUTO, who, buf, TELEGRAM);
- X
- Xsprintf(buf, "%s [%d] gives %s [%d] a ship.\n", Race->name, alien->name);
- X
- Xfor(i=1; i<=Numraces(); i++)
- X push_message(TELEG_PLAYER_AUTO, who, buf, TRANSFER);
- X
- Xfree(ship);
- Xfree(Race);
- Xfree(alien);
- X
- X}
- X
- X
- Xpage(Playernum, APcount0, argn, args)
- Xint Playernum;
- Xint APcount0;
- Xint argn;
- Xchar args[MAXARGS][COMMANDSIZE];
- X{
- Xint i, who, to_block, dummy, APcount;
- Xracetype *Race, *alien;
- X
- XAPcount = APcount0;
- Xto_block = 0;
- Xif(!strncmp(args[1], "block", strlen(args[1]))) {
- X to_block = 1;
- X notify(Playernum, "Paging alliance block.\n");
- X} else {
- X GetPlayer(args[1], &who, &alien);
- X if (who < 1 || who > Numraces() ) {
- X sprintf(buf,"No such player.\n");
- X notify(Playernum, buf);
- X return;
- X }
- XAPcount *= !alien->God;
- Xfree(alien);
- X}
- X
- X switch(Dir[Playernum-1].level) {
- X case LEVEL_UNIV:
- X sprintf(buf, "You can't make pages at universal scope.\n");
- X notify(Playernum, buf);
- X break;
- X default:
- X openstardata(&name_stardata);
- X free(Stars[Dir[Playernum-1].snum]);
- X getstar(name_stardata, &Stars[Dir[Playernum-1].snum], Dir[Playernum-1].snum);
- X close_file(name_stardata);
- X if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount)) {
- X free(Race);
- X return;
- X }
- X
- X openracedata(&name_racedata);
- X getrace(name_racedata, &Race, Playernum);
- X close_file(name_racedata);
- X
- X sprintf(buf, "%s page(s) you from the %s star system.\n",
- X Race->name, Stars[Dir[Playernum-1].snum]->name);
- X free(Race);
- X
- X if(to_block) {
- X dummy = (Blocks[Playernum-1].invite &
- X Blocks[Playernum-1].pledge);
- X for(i=1; i<=Numraces(); i++)
- X if(isset(dummy, i) && i!=Playernum)
- X notify(i, buf);
- X } else
- X notify(who, buf);
- X
- X notify(Playernum, "Request sent.\n");
- X break;
- X }
- X deductAPs(Playernum, APcount, Dir[Playernum-1].snum, 0);
- X}
- X
- Xsend_message(Playernum, APcount0, argn, args)
- Xint Playernum;
- Xint APcount0;
- Xint argn;
- Xchar args[MAXARGS][COMMANDSIZE];
- X{
- Xint who, i, j, to_block, dummy, APcount;
- Xracetype *Race, *alien;
- X
- X APcount = APcount0;
- X Num_races = Numraces();
- X
- Xto_block = 0;
- Xif(!strncmp(args[1], "block", strlen(args[1]))) {
- X to_block = 1;
- X notify(Playernum, "Sending message to alliance block.\n");
- X} else {
- X GetPlayer(args[1], &who, &alien);
- X if (who < 1 || who > Num_races ) {
- X sprintf(buf,"No such player.\n");
- X notify(Playernum, buf);
- X return;
- X }
- XAPcount *= !alien->God;
- Xfree(alien);
- X}
- X
- X switch(Dir[Playernum-1].level) {
- X case LEVEL_UNIV:
- X sprintf(buf, "You can't send messages from universal scope.\n");
- X notify(Playernum, buf);
- X return;
- X break;
- X
- X case LEVEL_SHIP:
- X sprintf(buf, "You can't send messages from ship scope.\n");
- X notify(Playernum, buf);
- X return;
- X break;
- X
- X default:
- X openstardata(&name_stardata);
- X free(Stars[Dir[Playernum-1].snum]);
- X getstar(name_stardata, &Stars[Dir[Playernum-1].snum], Dir[Playernum-1].snum);
- X close_file(name_stardata);
- X if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount))
- X return;
- X break;
- X }
- X
- Xopenracedata(&name_racedata);
- Xgetrace(name_racedata, &Race, Playernum);
- Xclose_file(name_racedata);
- X
- X /* send the message */
- X sprintf(msg, "From %s [%d]: ", Race->name, Playernum);
- X
- X/* put the message together */
- X for(j=2; j < argn; j++)
- X {
- X sprintf(buf, "%s ", args[j]);
- X strcat(msg, buf);
- X }
- X/* post it */
- X sprintf(buf, "%s has sent you a telegram. Use `read' to read it.\n", Race->name);
- X if(to_block) {
- X dummy = (Blocks[Playernum-1].invite &
- X Blocks[Playernum-1].pledge);
- X sprintf(buf, "%s [%d] sends a message to alliance block.\n",
- X Race->name, Playernum);
- X for(i=1; i<=Num_races; i++) {
- X if(isset(dummy, i) && i!=Playernum) {
- X notify(i, buf);
- X push_message(Playernum, i, msg, TELEGRAM);
- X }
- X push_message(TELEG_PLAYER_AUTO, i, buf, TRANSFER);
- X }
- X } else {
- X notify(who, buf);
- X push_message(Playernum, who, msg, TELEGRAM);
- X
- X openracedata(&name_racedata);
- X getrace(name_racedata, &alien, who);
- X
- X sprintf(buf, "%s [%d] sends a message to %s [%d].\n",
- X Race->name, Playernum, alien->name, who);
- X
- X for(i=1; i<=Num_races; i++)
- X push_message(TELEG_PLAYER_AUTO, i, buf, TRANSFER);
- X
- X /* translation modifier increases */
- X alien->translate[Playernum-1] = MIN(alien->translate[Playernum-1]+2, 100);
- X putrace(name_racedata, alien);
- X close_file(name_racedata);
- X free(alien);
- X }
- X
- X free(Race);
- X notify(Playernum, "Message sent.\n");
- XdeductAPs(Playernum, APcount, Dir[Playernum-1].snum, 0);
- X}
- X
- Xread_messages(Playernum, APcount, argn, args)
- Xint Playernum;
- Xint APcount;
- Xint argn;
- Xchar args[MAXARGS][COMMANDSIZE];
- X{
- Xint i;
- X i = strlen(args[1]);
- X
- X if(argn==1 || !strncmp("telegram", args[1], i))
- X teleg_read(Playernum, TELEGRAM);
- X else if(!strncmp("news", args[1], i)) {
- X notify(Playernum, CUTE_MESSAGE);
- X notify(Playernum, "\n---------- Politics ----------\n");
- X teleg_read(Playernum, DECLARATION);
- X notify(Playernum, "\n---------- War Stories ----------\n");
- X teleg_read(Playernum, COMBAT);
- X notify(Playernum, "\n---------- Wheelin' and Dealin' ----------\n");
- X teleg_read(Playernum, TRANSFER);
- X notify(Playernum, "\n---------- Classifieds ----------\n");
- X teleg_read(Playernum, ANNOUNCE);
- X } else
- X notify(Playernum, "Read what?\n");
- X }
- X
- X
- Xannounce(Playernum, APcount, argn, args, broadcast)
- Xint Playernum;
- Xint APcount;
- Xint argn;
- Xchar args[MAXARGS][COMMANDSIZE];
- Xint broadcast;
- X{
- Xint i, j;
- Xracetype *r, *Race;
- X
- Xopenracedata(&name_racedata);
- Xgetrace(name_racedata, &Race, Playernum);
- Xclose_file(name_racedata);
- X
- Xswitch(Dir[Playernum-1].level) {
- X case LEVEL_UNIV:
- X sprintf(buf, "You can't make announcements at universal scope.\n");
- X notify(Playernum, buf);
- X break;
- X default:
- X openstardata(&name_stardata);
- X free(Stars[Dir[Playernum-1].snum]);
- X getstar(name_stardata, &Stars[Dir[Playernum-1].snum], Dir[Playernum-1].snum);
- X close_file(name_stardata);
- X if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount)) {
- X free(Race);
- X return;
- X
- X }
- X if(!(!!isset(Stars[Dir[Playernum-1].snum]->inhabited, Playernum) || Race->God)) {
- X sprintf(buf, "You do not inhabit this system or have diety privileges.\n");
- X notify(Playernum, buf);
- X free(Race);
- X return;
- X }
- X
- Xif(!broadcast)
- X sprintf(msg, "%s : ", Race->name);
- Xelse
- X sprintf(msg, "%s [%d] > ", Race->name, Playernum);
- X
- X Num_races = Numraces();
- X
- X for(j=1; j < argn; j++)
- X {
- X sprintf(buf, "%s ", args[j]);
- X strcat(msg, buf);
- X }
- X strcat(msg, "\n");
- X
- X for(i=1; i<=Num_races; i++)
- X if(i != Playernum) {
- X openracedata(&name_racedata);
- X getrace(name_racedata, &r, i);
- X close_file(name_racedata);
- X
- X if((broadcast && !r->gag) || (Dir[i-1].level != LEVEL_UNIV && (Dir[i-1].snum == Dir[Playernum-1].snum)
- X && (!!isset(Stars[Dir[Playernum-1].snum]->inhabited, i) || Race->God)))
- X notify(i, msg);
- X free(r);
- X }
- X
- X break;
- X }
- X
- X deductAPs(Playernum,APcount, Dir[Playernum-1].snum, 0);
- Xfree(Race);
- X}
- X
- X
- Xmotto(Playernum, APcount, argn, args)
- Xint Playernum;
- Xint APcount;
- Xint argn;
- Xchar args[MAXARGS][COMMANDSIZE];
- X{
- Xint i;
- Xchar temp[128];
- X
- Xsprintf(buf, "%s", args[1]);
- X for(i=2; i < argn; i++)
- X {
- X sprintf(temp, " %s", args[i]);
- X strcat(buf, temp);
- X }
- X
- X sprintf(Blocks[Playernum-1].motto, "%s", buf);
- X Putblock(Blocks);
- X notify(Playernum, "Done.\n");
- X}
- X
- Xname(Playernum,APcount, argn,args)
- Xint Playernum;
- Xint APcount;
- Xint argn;
- Xchar args[MAXARGS][COMMANDSIZE];
- X{
- Xchar *ch;
- Xregister int i, s, spaces;
- Xboolean check=0;
- Xshiptype *ship;
- Xstartype *star;
- Xplanettype *p;
- Xchar string[1024];
- Xchar temp[128];
- Xracetype *Race;
- X
- Xname_stardata = NEUTRAL_FD;
- X
- Xif(!isalnum(args[2][0]) || argn < 3) {
- X notify(Playernum, "Illegal name format.\n");
- X return;
- X }
- X
- Xsprintf(buf, "%s", args[2]);
- X for(i=3; i < argn; i++)
- X {
- X sprintf(temp, " %s", args[i]);
- X strcat(buf, temp);
- X }
- X
- Xsprintf(string, "%s", buf);
- X
- X i=strlen(args[0]);
- X
- X /* make sure there are no ^'s or '/' in name,
- X also make sure the name has at least 1 character in it */
- X ch = string;
- X spaces = 0;
- X while (*ch!='\0') {
- X check |= ((!isalnum(*ch) && !(*ch==' ')) || (*ch=='/') );
- X ch++;
- X if(*ch==' ') spaces++;
- X }
- X
- X if(spaces==strlen(buf)) {
- X notify(Playernum, "Illegal name.\n");
- X return;
- X }
- X
- X if (strlen(buf) < 1 || check) {
- X sprintf(buf, "Illegal name %s.\n", check ? "form" : "length" );
- X notify(Playernum, buf);
- X return;
- X }
- X
- X if (!strncmp(args[1],"ship",i)) {
- X if(Dir[Playernum-1].level == LEVEL_SHIP) {
- X openshdata(&name_shdata);
- X getship(name_shdata, &ship, Dir[Playernum-1].shipno);
- X
- X sprintf(ship->name, "%s", buf);
- X putship(name_shdata, ship, Dir[Playernum-1].shipno);
- X close_file(name_shdata);
- X notify(Playernum, "Name set.\n");
- X free(ship);
- X return;
- X } else {
- X notify(Playernum, "You have to 'cs' to a ship to name it.\n");
- X return;
- X }
- X } else if (!strncmp(args[1],"class",i)) {
- X if(Dir[Playernum-1].level == LEVEL_SHIP) {
- X openshdata(&name_shdata);
- X getship(name_shdata, &ship, Dir[Playernum-1].shipno);
- X close_file(name_shdata);
- X if(ship->type != OTYPE_FACTORY) {
- X notify(Playernum, "You are not at a factory!\n");
- X free(ship);
- X return;
- X }
- X if(ship->on) {
- X notify(Playernum, "This factory is already on line.\n");
- X free(ship);
- X return;
- X }
- X
- X sprintf(ship->class, "%s", buf);
- X openshdata(&name_shdata);
- X putship(name_shdata, ship, Dir[Playernum-1].shipno);
- X close_file(name_shdata);
- X notify(Playernum, "Class set.\n");
- X free(ship);
- X return;
- X } else {
- X notify(Playernum, "You have to 'cs' to a factory to name the ship class.\n");
- X return;
- X }
- X } else if (!strncmp(args[1], "block", i)) {
- X/* name your alliance block */
- X sprintf(Blocks[Playernum-1].name, "%s", buf);
- X Putblock(Blocks);
- X notify(Playernum, "Done.\n");
- X }else if (!strncmp(args[1],"star",i)) {
- X
- X if(Dir[Playernum-1].level == LEVEL_STAR) {
- X openracedata(&name_racedata);
- X getrace(name_racedata, &Race, Playernum);
- X close_file(name_racedata);
- X if (!Race->God) {
- X notify(Playernum, "Only dieties may name a star.\n");
- X free(Race);
- X return;
- X }
- X free(Race);
- X/* got to get all stars, to stop cheaters */
- X openstardata(&name_stardata);
- X for (s=0; s<Sdata.numstars; s++) {
- X free(Stars[s]);
- X getstar(name_stardata, &Stars[s], s);
- X }
- X close_file(name_stardata);
- X
- X for(s=0; s<Sdata.numstars; s++) {
- X if(s!=Dir[Playernum-1].snum)
- X if(!strncmp(Stars[s]->name, buf, strlen(Stars[s]->name)))
- X {
- X notify(Playernum,
- X "Thats not fair trying to name a star that! 50 APs deducted for cheating!!!\n");
- X return;
- X }
- X }
- X
- X
- X/* check to see if there are any other stars with this name - stops cheaters */
- X
- X
- Xsprintf(Stars[Dir[Playernum-1].snum]->name, "%s", buf);
- X openstardata(&name_stardata);
- X putstar(name_stardata, Stars[Dir[Playernum-1].snum],
- X Dir[Playernum-1].snum);
- X close_file(name_stardata);
- X } else {
- X notify(Playernum, "You have to 'cs' to a star to name it.\n");
- X return;
- X }
- X } else if (!strncmp(args[1],"planet",i)) {
- X if(Dir[Playernum-1].level == LEVEL_PLAN) {
- X free(Stars[Dir[Playernum-1].snum]);
- X openstardata(&name_stardata);
- X getstar(name_stardata, &Stars[Dir[Playernum-1].snum], Dir[Playernum-1].snum);
- X close_file(name_stardata);
- X
- X openracedata(&name_racedata);
- X getrace(name_racedata, &Race, Playernum);
- X close_file(name_racedata);
- X
- X if (!Race->God && !MostAPs(Playernum,Stars[Dir[Playernum-1].snum])) {
- X notify(Playernum,"You don't have the most AP's in that system.\n");
- X free(Race);
- X return;
- X }
- X free(Race);
- X
- X for(s=0; s<Stars[Dir[Playernum-1].snum]->numplanets; s++)
- X if(!strncmp(Stars[Dir[Playernum-1].snum]->pnames[s], buf,
- X strlen(Stars[Dir[Playernum-1].snum]->pnames[s])))
- X {
- X notify(Playernum,
- X "Sorry, that name is already taken. 50 APs deducted for cheating!!!\n");
- X return;
- X }
- X
- X
- Xsprintf(Stars[Dir[Playernum-1].snum]->pnames[Dir[Playernum-1].pnum], "%s", buf);
- X openstardata(&name_stardata);
- X putstar(name_stardata, Stars[Dir[Playernum-1].snum], Dir[Playernum-1].snum);
- X close_file(name_stardata);
- X deductAPs(Playernum, APcount, Dir[Playernum-1].snum, 0);
- X
- X } else {
- X notify(Playernum, "You have to 'cs' to a planet to name it.\n");
- X return;
- X }
- X } else if (!strncmp(args[1],"race",i)) {
- X openracedata(&name_racedata);
- X getrace(name_racedata, &Race, Playernum);
- X sprintf(Race->name, "%s", buf);
- X putrace(name_racedata, Race);
- X close_file(name_racedata);
- X free(Race);
- X } else {
- X notify(Playernum, "I don't know what you mean.\n");
- X return;
- X }
- X
- X}
- X
- X
- Xint MostAPs(Playernum,s)
- Xint Playernum;
- Xstartype *s;
- X{
- X register int i,t = 0;
- X
- X for (i=0; i<MAXPLAYERS; i++)
- X if (s->AP[i] >= t)
- X t = s->AP[i];
- X
- X return (s->AP[Playernum-1] == t);
- X
- X}
- X
- X
- END_OF_FILE
- if test 17264 -ne `wc -c <'server/name.c'`; then
- echo shar: \"'server/name.c'\" unpacked with wrong size!
- fi
- # end of 'server/name.c'
- echo shar: End of archive 6 \(of 9\).
- cp /dev/null ark6isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 9 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-